package com.tanglon.config;

import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.annotation.EnableRabbit;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableRabbit
public class RabbitMQConfig {

    // 定义用于传递文章浏览消息的队列
    public static final String ARTICLE_VIEW_QUEUE = "article.view.queue";

    @Bean
    public Queue articleViewQueue() {
        //  durable: true 表示队列持久化
        return new Queue(ARTICLE_VIEW_QUEUE, true);
    }

    @Bean
    public MessageConverter messageConverter() {
        return  new Jackson2JsonMessageConverter();
    }
}